import { ResultEnum} from "../src/enums/httpEnums";
import exp = require("constants");

export function resultError(
    message = 'Request failed',
    {code = ResultEnum.ERROR, data= null} = {}
){
    return {
        code,
        data,
        message,
        type:'error'
    }
}

export function resultSuccess<T>(data: T, { message = 'ok' } = {}) {
    return {
        code: ResultEnum.SUCCESS,
        data,
        message,
        type: 'success',
    }
}

export interface requestParams {
    method: string
    body: any
    headers?: { authorization?: string}
    query:any
}

export function getRequestToken({
    headers,}:requestParams): string |undefined{
    return headers?.authorization
}

